<template>
  <div class="terms-container">
    <!-- 顶部返回按钮 -->
    <div class="top-bar">
      <button @click="handleBack" class="back-btn">
        <svg
          xmlns="http://www.w3.org/2000/svg"
          width="22"
          height="22"
          viewBox="0 0 24 24"
          fill="none"
          stroke="currentColor"
          stroke-width="2"
          stroke-linecap="round"
          stroke-linejoin="round">
          <path d="m12 19-7-7 7-7" />
          <path d="M19 12H5" />
        </svg>
        <span class="back-text">Back</span>
      </button>
    </div>

    <!-- 内容区 -->
    <main class="terms-content">
      <div class="terms-slogan">From Spark to Storefront. Your Imagination, Made Real.</div>

      <div class="terms-intro">
        Welcome to Nexbie, the place where your creativity gets real. We saw a universe of
        incredible ideas trapped on screens, held back by the complexities of turning digital art
        into physical products. We knew there had to be a better way.
      </div>

      <div class="terms-description">
        Nexbie is a one-stop community built for the new wave of AIGC creators. We are a platform
        designed to empower every user to complete the entire journey from a creative spark to a
        commercial success. Whether you're a master of prompts or a visionary designer, our tools
        are built to bring your concepts to life.
      </div>

      <!-- 条款列表（直接展示所有内容，无折叠效果） -->
      <section class="terms-list">
        <div class="term-item" v-for="(term, index) in terms" :key="index">
          <!-- 条款标题 -->
          <div class="term-title">
            <span class="term-heading">{{ term.title }}</span>
          </div>

          <!-- 条款内容（直接展示） -->
          <div class="term-content">
            <div class="content-inner" v-html="formatContent(term.content)"></div>
          </div>
        </div>
      </section>

      <div class="terms-conclusion">
        We believe that every creator deserves a straightforward path to monetization. Nexbie is our
        answer. It's more than a platform; it's a launchpad for your ambition.
      </div>

      <div class="terms-cta">Join us and build the future of creativity.</div>
    </main>
  </div>
</template>

<script setup>
  import { ref } from 'vue';
  import { useRouter } from 'vue-router';

  const router = useRouter();

  // 返回上一页
  const handleBack = () => {
    router.back();
  };

  // 条款数据
  const terms = ref([
    {
      title: 'What We Do:',
      content: `
      <strong>Create:</strong> Use our powerful Nex Lab AI tools to generate stunning designs from text or images. This is your personal creation engine.

      <strong>Launch:</strong> Turn your best work into a product with our unique "Nex" feature. It’s a micro-crowdfunding system where the community backs your design to make it a reality. If a design gets enough support, we produce it, and you earn it.

      <strong>Compete & Win:</strong> Showcase your skills in the Nexbie Arcade, our creative contest with real cash prizes. It's your stage to get noticed and rewarded.
    `,
    },
  ]);

  // 内容格式化函数 - 保留strong标签
  const formatContent = (text) => {
    // 只移除HTML注释，保留允许的标签
    let formatted = text.replace(/<!--[\s\S]*?-->/g, '');

    // 处理换行符，转换为适当的段落分隔
    formatted = formatted
      .trim()
      .replace(/\n\s*\n/g, '</p><p class="term-paragraph">') // 空行转换为段落分隔
      .replace(/\n/g, '<br>'); // 单行换行转换为换行符

    // 包裹段落标签
    if (!formatted.startsWith('<p')) {
      formatted = `<p class="term-paragraph">${formatted}</p>`;
    }

    return formatted;
  };
</script>

<style scoped>
  /* 全局样式 */
  .terms-container {
    width: 100%;
    min-height: 100vh;
    background-color: #f8f8f8;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    margin: 0;
    padding: 0;
    padding-top: 54px;
  }

  /* 顶部返回栏 */
  .top-bar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 54px;
    padding: 0 20px;
    background-color: #fff;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
    z-index: 100;
    display: flex;
    align-items: center;
    border-bottom: 1px solid #f0f0f0;
  }

  .back-btn {
    display: inline-flex;
    align-items: center;
    background: transparent;
    border: none;
    color: #333;
    font-size: 15px;
    font-weight: 500;
    cursor: pointer;
    padding: 0;
    margin: 0;
    height: 100%;
  }

  .back-btn svg {
    margin-right: 8px;
    color: #f76b1b;
    flex-shrink: 0;
  }

  .back-text {
    transition: color 0.2s ease;
    flex-shrink: 0;
  }

  .back-btn:hover .back-text {
    color: #f76b1b;
  }

  /* 内容区域 */
  .terms-content {
    padding: 0 20px 40px;
    max-width: 800px;
    margin: 0 auto;
  }

  /* 标语样式 */
  .terms-slogan {
    font-size: 22px;
    font-weight: 700;
    color: #333;
    margin: 0 0 24px;
    line-height: 1.4;
    padding-bottom: 16px;
    border-bottom: 1px solid #f0f0f0;
  }

  /* 介绍文本样式 */
  .terms-intro {
    font-size: 16px;
    color: #333;
    line-height: 1.8;
    margin-bottom: 20px;
  }

  /* 描述文本样式 */
  .terms-description {
    font-size: 15px;
    color: #333;
    line-height: 1.8;
    margin-bottom: 28px;
  }

  /* 条款列表 */
  .terms-list {
    background-color: #fff;
    border-radius: 12px;
    padding: 10px 0;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.05);
    margin-bottom: 28px;
  }

  /* 条款项 */
  .term-item {
    border-bottom: none;
  }

  /* 条款标题（无折叠图标） */
  .term-title {
    padding: 18px 20px 8px;
  }

  .term-heading {
    font-size: 17px;
    font-weight: 600;
    color: #333;
  }

  /* 条款内容区域（直接展示） */
  .term-content {
    padding: 0;
    overflow: visible;
  }

  /* 内容内部容器 */
  .content-inner {
    padding: 0 24px 20px;
    font-size: 15px;
    color: #333;
    line-height: 2;
  }

  /* Strong标签样式 */
  .content-inner strong {
    color: #f76b1b;
    font-weight: 600;
    margin-right: 8px;
  }

  /* 段落样式 */
  .term-paragraph {
    margin: 0 0 16px;
    line-height: 2;
  }

  .term-paragraph:last-child {
    margin-bottom: 0;
  }

  /* 结论文本 */
  .terms-conclusion {
    font-size: 15px;
    color: #333;
    line-height: 1.8;
    margin-bottom: 20px;
    padding: 16px;
    background-color: #fff;
    border-radius: 8px;
    box-shadow: 0 1px 6px rgba(0, 0, 0, 0.05);
  }

  /* 行动号召文本 */
  .terms-cta {
    font-size: 16px;
    font-weight: 600;
    color: #f76b1b;
    line-height: 1.6;
    text-align: center;
    margin-top: 30px;
  }

  /* 响应式调整 */
  @media (max-width: 375px) {
    .terms-container {
      padding-top: 50px;
    }

    .top-bar {
      height: 50px;
      padding: 0 16px;
    }

    .terms-content {
      padding: 0 16px 30px;
    }

    .terms-slogan {
      font-size: 19px;
      margin-bottom: 20px;
      padding-bottom: 12px;
    }

    .terms-intro {
      font-size: 15px;
      line-height: 1.7;
      margin-bottom: 16px;
    }

    .terms-description {
      font-size: 14px;
      line-height: 1.7;
      margin-bottom: 24px;
    }

    .term-title {
      padding: 16px 16px 8px;
    }

    .term-heading {
      font-size: 16px;
    }

    .content-inner {
      padding: 0 20px 18px;
      font-size: 14px;
      line-height: 1.9;
    }

    .terms-conclusion {
      font-size: 14px;
      padding: 14px;
      margin-bottom: 16px;
    }

    .terms-cta {
      font-size: 15px;
      margin-top: 24px;
    }
  }
</style>
